package org.csu.mypetstoreback.service;

import org.csu.mypetstoreback.domain.Order;
import org.csu.mypetstoreback.persistence.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public List<Order> getOrders(){
        return orderMapper.getOrders();
    }

    public List<Order>  getWaitOrders(){return orderMapper.getWaitOrders();}

    public List<Order> getDeliveredOrders(){return orderMapper.getDeliveredOrders();}

    public List<Order>getOrdersByUserId(String username){return orderMapper.getOrdersByUserId(username);}

    public Order getOrder(int orderId){
        return orderMapper.getOrder(orderId);
    }

    public void deleteOrder(int orderId){
        orderMapper.deleteOrder(orderId);
        orderMapper.deleteOrderStatus(orderId);
    }

    public void updateOrder(Order order){
        orderMapper.updateOrder(order);
        orderMapper.updateOrderStatus(order);
    }

}
